package com.synnex.salesorderportal.dao.entity;

import lombok.*;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;

/**
 * Created by yachao on 18/5/31.
 */
@Embeddable
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class OrderDetailId implements Serializable {
    private static final long serialVersionUID = 7515374125854721513L;

    @AttributeOverrides({
            @AttributeOverride(name = "orderType", column = @Column(name = "order_type")),
            @AttributeOverride(name = "orderNo", column = @Column(name = "order_no"))
    })
    private OrderId orderId;

    @Column(name = "order_line_no")
    private Integer orderLineNo;

    public OrderDetailId(Integer orderType, Integer orderNo, Integer orderLineNo) {
        this.orderId = new OrderId(orderType, orderNo);
        this.orderLineNo = orderLineNo;
    }

    @Override
    public String toString() {
        return "OrderDetailId{" +
                "orderId=" + orderId +
                ", orderLineNo=" + orderLineNo +
                '}';
    }
}
